package myThread;

import static java.lang.Thread.sleep;

public class demo17 {
    private static int count = 0;
    public  synchronized static void method() throws InterruptedException {
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 50000; i++) {

                    demo17.count++;

            }
        });
        t1.start();
        //return t1;
    }

    public static void main(String[] args) throws InterruptedException {
        demo17 d3 = new demo17();
        d3.method();
        //d3.method();

        demo17 d4 = new demo17();
        d4.method();
        sleep(2000);
        System.out.println(demo17.count);

//        demo17 d1 = new demo17();
//
//        Thread T1 = d1.method();
//        T1.start();
//        T1.join();

//        Thread T2 = d1.method();
//        T2.start();
//        T2.join();

//        demo17 d2 = new demo17();
//        Thread T3 = d2.method();
//        T3.start();
//        T3.join();

    }
}
